<?php
/**
 * Created by PhpStorm.
 * User: Mak
 * Date: 2016/3/12
 * Time: 13:47
 */

namespace Home\Controller;
use Think\Controller;

class LoginController extends Controller{
    public function index(){
        layout(false);
        $this->display();
    }

    public function login(){
        $username=htmlspecialchars(trim(I("post.username")));
        $password=htmlspecialchars(trim(I("post.password")));

        $stuInfo=D("StuInfo");
        $res=$stuInfo->checkUser($username,$password);
        if($res==1){
            session("username",$username);
            redirect(U('Index/index'));
        }elseif($res==0){
            $this->error("密码错误！");
        }elseif($res==-1){
            $this->error("帐号不存在！");
        }
    }

    public function logout(){
        session(null);
        redirect(U('Index/index'));
    }

    public function putClass(){

    }
}